export const statusList1 = [
  {
    min: 0,
    max: 0,
    color: '#FF453A',
    tip: '已经到期',
    tipColor: '#FF453A',
  },
  {
    min: 1,
    max: 5,
    color: '#FFAA39',
    tip: '即将到期',
    tipColor: '#FFAA39',
  },
  {
    min: 6,
    max: 100,
    color: '#408DF2',
    tip: '剩余寿命',
    tipColor: '#2D3746',
  },
]

export const statusList2 = [
  {
    min: 0,
    max: 0,
    color: '#FF453A',
    tip: '已经到期',
    tipColor: '#FF453A',
  },
  {
    min: 1,
    max: 10,
    color: '#FFAA39',
    tip: '即将到期',
    tipColor: '#FFAA39',
  },
  {
    min: 11,
    max: 100,
    color: '#408DF2',
    tip: '剩余寿命',
    tipColor: '#2D3746',
  },
]

export const favoritePictureListSIEMENS = [
  { url: 'AmbientWater_SE.jpg' },
  { url: 'BlackSesame_SE.jpg' },
  { url: 'Chocolate_SE.jpg' },
  { url: 'JuicePowder_SE.jpg' },
  { url: 'LotusRootStarch_SE.jpg' },
  { url: 'Matcha_SE.jpg' },
  { url: 'milktea_SE.jpg' },
  { url: 'Oatmeal_SE.jpg' },
  { url: 'ProteinPowder_SE.jpg' },
  { url: 'SoyabeanMilk_SE.jpg' },
  { url: 'MealReplacementPowder_SE.jpg' },
]

export const favoritePictureListBOSCH = [
  { url: 'img_hot_tea.jpg', nameZH: '红茶', nameEN: 'Hot Tea' },
  { url: 'img_matcha_tea.jpg', nameZH: '抹茶', nameEN: 'Matcha tea' },
  { url: 'img_soya_tea.jpg', nameZH: '豆浆', nameEN: 'Soya milk' },
  { url: 'img_oatmeal.jpg', nameZH: '麦片', nameEN: 'Oatmeal' },
  { url: 'img_meal_replacement_power.jpg', nameZH: '代餐粉', nameEN: 'Meal replancement power' },
  { url: 'img_albumen_power.jpg', nameZH: '蛋白粉', nameEN: 'Albumen power' },
  { url: 'img_hot_chocolate.jpg', nameZH: '热巧克力', nameEN: 'Hot chocolate' },
  { url: 'img_milk_tea.jpg', nameZH: '奶茶', nameEN: 'Milk tea' },
  { url: 'img_juice_power.jpg', nameZH: '果珍', nameEN: 'Juice power' },
  { url: 'img_milk_shake.jpg', nameZH: '奶昔', nameEN: 'Milk shake' },
  { url: 'img_black_sesame_paste1.jpg', nameZH: '芝麻糊', nameEN: 'Black sesame paste' },
  { url: 'img_lotus_root_starch.jpg', nameZH: '藕粉', nameEN: 'Lotus root starch' },
  { url: 'img_emptycup.jpg', nameZH: '其他', nameEN: 'Empty Cup' },
]

export type SleepTimeListType = {
  key: number
  value: string
}
export const sleepTimeListData: SleepTimeListType[] = [
  {
    key: 0,
    value: '30秒',
  },
  {
    key: 1,
    value: '1分钟',
  },
  {
    key: 2,
    value: '3分钟',
  },
  {
    key: 3,
    value: '5分钟',
  },
]

export function EncodeUnicode(str: string) {
  let res = []
  for (let i = 0; i < str.length; i++) {
    res[i] = ('00' + str.charCodeAt(i).toString(16)).slice(-4)
  }
  return '\\u' + res.join('\\u')
}

export function NameToArray(name: string) {
  let encodeData = EncodeUnicode(name)
  let encodeArray = encodeData.split('\\u')
  encodeArray.shift()
  let allArray = ['0000', '0000', '0000', '0000', '0000', '0000', '0000', '0000', '0000', '0000']
  for (var j = 0; j < encodeArray.length; j++) {
    allArray[j] = encodeArray[j]
  }
  let fav_name1 = parseInt(allArray[0].substring(2, 4) + allArray[0].substring(0, 2), 16)
  let fav_name2 = parseInt(allArray[1].substring(2, 4) + allArray[1].substring(0, 2), 16)
  let fav_name3 = parseInt(allArray[2].substring(2, 4) + allArray[2].substring(0, 2), 16)
  let fav_name4 = parseInt(allArray[3].substring(2, 4) + allArray[3].substring(0, 2), 16)
  let fav_name5 = parseInt(allArray[4].substring(2, 4) + allArray[4].substring(0, 2), 16)
  let fav_name6 = parseInt(allArray[5].substring(2, 4) + allArray[5].substring(0, 2), 16)
  let fav_name7 = parseInt(allArray[6].substring(2, 4) + allArray[6].substring(0, 2), 16)
  let fav_name8 = parseInt(allArray[7].substring(2, 4) + allArray[7].substring(0, 2), 16)
  let fav_name9 = parseInt(allArray[8].substring(2, 4) + allArray[8].substring(0, 2), 16)
  let fav_name10 = parseInt(allArray[9].substring(2, 4) + allArray[9].substring(0, 2), 16)
  return [fav_name1, fav_name2, fav_name3, fav_name4, fav_name5, fav_name6, fav_name7, fav_name8, fav_name9, fav_name10]
}

/**
 * 补零
 * @param num
 * @param n
 * @returns
 */
export function prefixZero(num: string | number, n: number) {
  if (num === undefined) return
  return (Array(n).join('0') + num).slice(-n)
}

/**
 * 生成夜间模式时间可选择时间
 */
export function generateNightModeTimeList(isStart: boolean, hour: number, minute: number) {
  let timeArray = []
  for (let i = 0; i <= hour; i++) {
    let tmpHour = ''
    if (i < 10) {
      tmpHour = '0' + i
    } else {
      tmpHour = i + ''
    }
    let tmpEndMinute = 60
    let tmpStartMinute = 0
    let tmpMinuteList = []
    if (i === hour) {
      tmpEndMinute = minute
    }

    if (i == 0 && isStart == true) {
      tmpStartMinute = 1
    }
    for (let j = tmpStartMinute; j < tmpEndMinute; j++) {
      if (j < 10) {
        tmpMinuteList.push('0' + j)
      } else {
        tmpMinuteList.push(j + '')
      }
    }
    if (tmpMinuteList.length > 0) {
      timeArray.push({
        hour: tmpHour,
        minute: tmpMinuteList,
      })
    }
  }
  return timeArray
}
